<?php
	defined('_JEXEC') or die('Restricted access');
	require_once(CUTEENGINE_BASE_FIELD_PATH."base_field_class.php");
    
	//
    // t_field_custom_code
    //
	class t_field_custom_code extends t_base_field
	{
        
        // property declaration
		// protected

        

        // property declaration
		// public
		// G
		const language_position_last = 1;
		
		// C
		const custom_code_type_tag_property = 1;
		const custom_code_type_text_to_include = 2;
		const custom_code_type_custom_file = 3;
		const custom_code_type_last = 4;
		// P
		const proper_properties_position_custom_code_type = 1;
		const proper_properties_position_param_1 = 2;
		const proper_properties_position_param_2 = 3;
		const proper_properties_position_param_3 = 4;
		const proper_properties_position_param_4 = 5;
        const proper_properties_position_last = 6;

        // method declaration
    	// protected
		// C
        // G
		protected function get_field_event_script($a_event_type,$a_argouments)
        {			
			//echo "a_event_type:$a_event_type<BR>";
			$local_return = '';
			return $local_return;
		}
static function get_help_proper_property($a_index)
		{
			$local_return = 'NO HELP AVAILABLE';
			/*switch ($a_index) 
            {
                case self::proper_properties_position_:
					$local_return = '';
				break;                
			}*/
			return $local_return;
		}
        static function get_default_proper_property($a_index)
		{
			$local_return = '';
			/*switch ($a_index) 
            {
                case self::proper_properties_position_:
					$local_return = 'TRUE';
				break;                
			}*/
			return $local_return;
		}
		protected function get_proper_properties_position_last()      
		{
            return self::proper_properties_position_last;
        }
		
	
		
        // method declaration
    	// public
        public function __construct($a_parent_part,$a_common_properties_str, $a_proper_properties_str)
		{
            parent::__construct($a_parent_part,$a_common_properties_str, $a_proper_properties_str);
            
			
		}

        // C
		public function create_tags_structure()
        {
            //echo __METHOD__."<BR>";
            global $g_javascript_namespace;
			parent::create_tags_structure();
			// method

			// component
            $local_name = $this->common_properties_array[t_base_field::common_properties_position_per_field_name];
            $local_current_tag = parent::add_tag(t_base_tag_type::btt_div,
                $local_name);
			$this->main_tag = $local_current_tag;
            $this->default_start_tag = $this->main_tag;
            $this->default_result_tag = $this->main_tag;
            // 
			switch ($this->proper_properties_array[self::proper_properties_position_custom_code_type]) 
			{
				/*  self::t_primary_condition_type_no_condition:  */
				case self::custom_code_type_tag_property:
					$this->main_tag->add_property($this->proper_properties_array[self::proper_properties_position_param_1],
						$this->proper_properties_array[self::proper_properties_position_param_2]);
				break;
				case self::custom_code_type_text_to_include:
					$this->main_tag->add_text_to_include(str_replace('__CE_CURRENT_URL__',"http://".$_SERVER["SERVER_NAME"].substr($_SERVER["REQUEST_URI"],0,strlen('/'.$_SERVER["QUERY_STRING"]))/*$_SERVER["REQUEST_URI"]*/,
						$this->proper_properties_array[self::proper_properties_position_param_1]));
				break;
				case self::custom_code_type_custom_file:
					$local_file = CUTEENGINE_PATH_CUSTOM_FILES . $this->proper_properties_array[self::proper_properties_position_param_1];
					//echo "local_file: $local_file<br>";
					if (file_exists($local_file))
						require($local_file);
				break;
			}	
            
            
        }
		public function create_javascript_initialization_component()
		{
			
		}
        
		// G
		public function get_language_position_last()
        {
            return self::language_position_last;
        }
		public function get_result_action_script($a_event_type,$parent_event_type,
            $a_parameter,$a_content_loader_result)
		{
            return '';
        }
		// I
		public function initialize_field_event($a_event_type)
        {	
			//echo "ciao";
		}
    }
?>    